m4_include([ax_boost_base.m4])

AC_INIT([glmblock],[0.2],[ypark28@jhu.edu])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE

AC_CHECK_HEADER_STDBOOL
AC_C_RESTRICT
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T

# Checks for header files.
AC_CHECK_HEADERS([stdlib.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_INSTALL

AX_BOOST_BASE([1.40.0])
AC_PROG_MKDIR_P
AC_CHECK_PROG([MKTEMP],[mktemp])

# Checks for library functions.
AC_CHECK_LIB([m], [floor, pow, exp, log])
# AC_CHECK_LIB([gsl], [gsl_sf_psi_1])

# init
AM_INIT_AUTOMAKE([-Wall foreign])

CXXFLAGS="$CXXFLAGS"
CFLAGS="$CFLAGS"

AC_ARG_ENABLE([debug],
              [AS_HELP_STRING([--enable-debug],
	                      [enable debugging info (default is no)])],
              [], [enable_debug=no])
AC_ARG_ENABLE([optim],
              [AS_HELP_STRING([--enable-optim@<:@=0|1|2|3@:>@],
	                      [set optimization level (default is 3)])],
              [if test "x$enable_optim" = xyes; then enable_optim=3; fi],
              [enable_optim=3])

AS_IF([test "x$enable_optim" != xno], 
	    [ext_CFLAGS="$ext_CFLAGS -O$enable_optim "])
AS_IF([test "x$enable_debug" = xyes],
      [debug_CFLAGS="-DDEBUG"],
      [debug_CFLAGS="-DNDEBUG -fomit-frame-pointer -funroll-loops -fexpensive-optimizations"])

CFLAGS="${generic_CFLAGS} ${ext_CFLAGS} ${user_CFLAGS} ${debug_CFLAGS}"
CXXFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS $BOOST_CPPFLAGS"
LDFLAGS="$user_LDFLAGS"


# makefiles to configure
AC_CONFIG_FILES([Makefile src/Makefile])

# make it happen
AC_OUTPUT
